<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<%@page import="com.huadragon.marathoncore.util.PropertyUtils"%>
<%@ page import="com.ckeditor.CKEditorConfig"%>
<%
String basePath =PropertyUtils.getProperty("java.renrenadmin.url");
String ImgShowUrl= PropertyUtils.getProperty("ImgShowUrl");
String titleString="";
String contentString="";
Integer Id=null;

%>
<% 
	CKEditorConfig settings = new CKEditorConfig();
	settings.addConfigValue("height","450");
	settings.addConfigValue("width","1000");
%>
<script src="/resource/manage/js/bootstrap-treeview.js"></script>
<div id="noshow" style="dispaly:none">
<%=contentString%>
</div>
<script>
$('#noshow').hide();
</script>
<span>文章标题：</span><input class="form-control" type="text" name="title" id="title" value="<%=titleString%>">
<br />
<span>内容：</span><br/>
<textarea name="content" id="editor" rows="5" cols="20"></textarea>
<ckeditor:replace replace="editor" basePath="/resource/manage/ckeditor4.0.2/" config="<%=settings %>"/>
<br/>
<input type="button" class="btn btn-w-m btn-primary" name="button" value="保存文章"  id="save"/>
<input type="button" class="btn btn-w-m btn-primary" name="button" value="预览文章"  id="show"/>
<div tabindex="-1" class="modal inmodal" id="alertbox" role="dialog" aria-hidden="true" style="display: none;">	
	
	<div class="modal-dialog">
		<div class="modal-content animated bounceInRight">
			<div class="modal-header">
				<button class="close" type="button" data-dismiss="modal">
					<span aria-hidden="true">×</span><span class="sr-only">关闭</span>
				</button>
				<h4 class="modal-title" id="articleTitle"></h4>				
			</div>
			<small class="font-bold">
				<div class="modal-body" id="articleBody">
				</div>
				<div class="modal-footer">
					<button class="btn btn-white" type="button" data-dismiss="modal">关闭</button>
				</div>
			</small>
		</div>
		<small class="font-bold"> </small>
	</div>
	<small class="font-bold"> </small>	
</div>

<script>
$('#show').click(function(){
	window.editor.sync();
	$('#articleBody').html($('#content').val());
	$('#articleTitle').html($('#title').val());
	$('#alertbox').modal('show'); 
});

$('#save').click(function(){
	window.editor.sync();
	var url="<%=basePath%>/article/savearticle";
	par={
			"title":$('#title').val(),
			"content":$('#content').val(),
			"id":<%=Id%>
	}
	$.post(url,par,function(data){
			if(data>0){
			alert('保存文章成功');
			window.location.href="<%=basePath%>/article/list";	
			}
			else
				alert('保存文章失败');
	});
});

</script>
